package com.blue.mountain.bluemountainjdk17.ai.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.RestController;

import groovy.util.logging.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


@RestController
@Slf4j
@Tag(name = "聊天接口", description = "AI 聊天相关接口")
public class ChatController {

    private final ChatClient chatClient;

    public ChatController(ChatClient.Builder builder) {
        this.chatClient = builder.defaultSystem("你是一个AI助手，你可以回答任何问题，你可以用中文回答").build();
    }

    @Operation(summary = "发起聊天", description = "根据输入消息与 AI 进行聊天")
    @GetMapping("/chat/{message}")
    public String getMethodName(@PathVariable("message") String message) {
        return chatClient.prompt().user(message).call().content();
    }

}
